// pages/warn/warn.js
Page({
  data: {
    dataList1: [],
    dataList: [],
    timeRangeIndex: 0,
    timeRange: ['2小时内', '4小时内', '24小时内'],
    date: '2024-01-01',//默认起始时间  
    date2: '2024-01-24',//默认结束时间 
    animate: 'myfirst',
    yesorno: 'none',
    flag: true,
    test:'test1',
    category: '', // 保存当前选中的类别
    feature: '' // 保存当前选中的特色
  },
  handleCategoryClick(e) {
    const category = e.currentTarget.dataset.category;
    this.setData({
      category
    });
  },
  handleFeatureClick(e) {
    const feature = e.currentTarget.dataset.feature;
    this.setData({
      feature
    });
  },
  clearSelection() {
    this.setData({
      category: '',
      feature: ''
    });
  },
  fabiao: function () {
    this.setData({
      yesorno: 'block'
    })
    this.setData({
      test: 'test1'
    })
    this.setData({
      flag: false
    })
  },
  laqi: function () {
    this.setData({
      test: 'test2',
    })
    this.setData({
      flag: true
    })
},

  bindTimeRangeChange: function (e) {
    this.setData({
      timeRangeIndex: e.detail.value
    });
  },

  // 时间段选择  
  bindDateChange(e) {
    let that = this;
    that.setData({
      date: e.detail.value,
    })
  },
  bindDateChange2(e) {
    let that = this;
    that.setData({
      date2: e.detail.value,
    })

  },

  onInput(e) {
    this.setData({
      keyword: e.detail.value
    });
    this.filterList();
  },
  goToDetail: function(event) {
     const id = event.currentTarget.dataset.id; 
     wx.navigateTo({ 
       url: '/pages/warnDetail/warnDetail?id=' + id, 
      });
     },
   
  onLoad(options) {
    wx.request({
      url: 'http://192.168.245.55:3000/api1/data',
      success: (res) => {
        this.setData({
          dataList: res.data,
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    wx.request({
      url: 'http://192.168.245.55:3000/selectById1/data',
      success: (res) => {
        this.setData({
          dataList1: res.data,
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },


  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },  
})